import { defineStore } from 'pinia'
import { ref } from 'vue'
import { userGetInfoService } from '@/api/user.js'

export const useUserStore = defineStore('big-event-user', () => {
  const token = ref('')
  const setToken = (newValue) => {
    token.value = newValue
  }
  const removeToken = () => {
    token.value = ''
  }
  const user = ref({})
  const getUser = async () => {
    const res = await userGetInfoService()
    user.value = res.data.data
  }
  const removeUser = () => {
    user.value = {}
  }
  return {
    token,
    setToken,
    removeToken,
    user,
    getUser,
    removeUser
  }
},{
  persist: true
})
